#include<iostream>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
LL cnt[N];
LL s[N];
LL ans;
int n, k;
int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		s[i] += s[i - 1];
	}
	cnt[0] = 1;
	for (int i = 1; i <= n; i++) {
		ans += cnt[s[i] % k];
		cnt[s[i] % k]++;
	}
	cout << ans << endl;
	return 0;
}